// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode 

package net.minecraft.src;

import java.util.Random;

// Referenced classes of package net.minecraft.src:
//            BlockBreakable, Material, IBlockAccess, World, 
//            Block, BlockFire, Entity, AxisAlignedBB

public class BlockPortalHistoric extends BlockBreakable
{

	public BlockPortalHistoric(int i, int j)
	{
		super(i, j, Material.portal, false);
	}

	public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
	{
		return null;
	}

	public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
	{
		setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
	}

	public boolean isOpaqueCube()
	{
		return false;
	}

	public boolean renderAsNormalBlock()
	{
		return false;
	}

	public void onNeighborBlockChange(World world, int x, int y, int z, int l)
	{
		boolean up = world.getBlockId(x, y + 1, z) == blockID;
		boolean down = world.getBlockId(x, y - 1, z) == blockID;
		
		if ((!up && !down))
		{
			world.setBlockWithNotify(x, y, z, 0);
			for(int j = -3; j < 1; j++)
			{
				if(world.getBlockId(x, y + j, z) == mod_pph.timeBox.blockID)
				{
					world.setBlockMetadata(x,y + j, z, 0);
					break;
				}
			}
		}
	}
	
	/*
	 * 0 - Bottom
	 * 1 - Top
	 * 2 - Front
	 * 3 - Back
	 * 4 - Left
	 * 5 - Right 
     */

	public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int face)
	{
		if (world.getBlockId(x, y, z) == blockID)
		{
			return false;
		}
		boolean left = world.getBlockId(x - 1, y, z) == blockID;
		boolean right = world.getBlockId(x + 1, y, z) == blockID;
		boolean back = world.getBlockId(x, y, z - 1) == blockID;
		boolean front = world.getBlockId(x, y, z + 1) == blockID;
		boolean top = world.getBlockId(x, y + 1, z) == blockID;
		boolean bot = world.getBlockId(x, y - 1, z) == blockID;
		if(!bot && face == 0)
			return true;
		if(!top  && face == 1)
			return true;
		if(!left && face == 4)
			return true;
		if(!right && face == 5)
			return true;
		if(!front && face == 3)
			return true;
		if(!back && face == 2)
			return true;
		return false;
	}

	public int quantityDropped(Random random)
	{
		return 0;
	}

	public int getRenderBlockPass()
	{
		return 1;
	}

	public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
	{
		if (entity.ridingEntity == null && entity.riddenByEntity == null && !mod_LoaderPPH.getPlayer().inPortal())
		{
			mod_LoaderPPH.getPlayer().setInPortal();
		}
	}

	public void randomDisplayTick(World world, int x, int y, int z, Random random)
	{
		if (random.nextInt(250) == 0)
		{
			world.playSoundEffect((double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "portal.portal", 1.0F, random.nextFloat() * 0.4F + 0.8F);
		}
		for (int l = 0; l < 10; l++)
		{
			double particleX = (float) x + random.nextFloat();
			double particleY = (float) y + random.nextFloat();
			double particleZ = (float) z + random.nextFloat();
			double motionX = 0.0D;
			double motionY = 0.0D;
			double motionZ = 0.0D;
			int i1 = random.nextInt(2) * 2 - 1;
			motionX = ((double) random.nextFloat() - 0.5D) * 0.5D;
			motionY = ((double) random.nextFloat() - 0.5D) * 0.5D;
			motionZ = ((double) random.nextFloat() - 0.5D) * 0.5D;
			//world.getBlockId(x - 1, y, z) == blockID /*|| world.getBlockId(x + 1, y, z) == blockID*/
			if (random.nextBoolean())
			{
				particleZ = (double) z + 0.5D + 0.25D * (double) i1;
				motionZ = random.nextFloat() * 3.0F * (float) i1;
			}
			else
			{
				particleX = (double) x + 0.5D + 0.25D * (double) i1;
				motionX = random.nextFloat() * 3.0F * (float) i1;
			}
			mod_LoaderPPH.SpawnParticle(new EntityPortalHistoricalFX(world, particleX, particleY, particleZ, motionX, motionY, motionZ));
		}

	}
}
